package com.lemon.boot;

import com.lemon.boot.common.utils.RequestUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

@Slf4j
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
        printAddress(context.getEnvironment());
    }

    /**
     * 打印地址
     *
     * @param environment
     */
    private static void printAddress(Environment environment) {
        log.info("\n----------------------------------------------------------\n\t" +
                        "Application '{}' is running! Access URLs:\n\t" +
                        "Local: \t\thttp://localhost:{}\n\t" +
                        "External: \t{}\n\t" +
                        "Doc: \t\t{}/doc.html\n" +
                        "----------------------------------------------------------",
                environment.getProperty("spring.application.name"),
                RequestUtil.getServerPort(),
                RequestUtil.getServerUrl(),
                RequestUtil.getServerUrl());
    }

}
